local match = string.match

function get_cookies()
  local cookies = ngx.header["Set-Cookie"] or {}
  if type(cookies) == "string" then
    cookies = {cookies}
  end
  return cookies
end
function add_cookie(cookie)
  local cookies = get_cookies()
  table.insert(cookies, cookie)
  ngx.header['Set-Cookie'] = cookies
end
function remove_cookie(cookie_name)
    local cookies = get_cookies()

    for key, value in ipairs(cookies) do
        local name = match(value, "(.-)=")
        if name == cookie_name then
            table.remove(cookies, key)
        end
    end
    ngx.header['Set-Cookie'] = cookies or {}
end

add_cookie("cdp_key= ; Path=/; Domain=.58.com")
add_cookie("cdp_user= ; Path=/; Domain=.58.com")
add_cookie("aaaa_bbbb=123456; Path=/; Domain=.58.com")

remove_cookie("cdp_key")
remove_cookie("cdp_user")

ngx.say('{"success": true}')